//! \file filestatus.hpp
//! \brief Purewell Library File Status Header
//! \author Yubin Lim (purewell@gmail.com)
//! \since 2008-01-25

#ifndef __FILESTATUS_HPP__
#define __FILESTATUS_HPP__

#include "types.hpp"
#include "file.hpp"

namespace purewell
{

//! \brief File status.
class PWFileStatus
{
public:
	//! \brief Get file status.
	//! \param[in] file File object.
	//! \return On success, true.
	bool getStatus(const PWFile& file);

	//! \brief Get file status.
	//! \param[in] fd File descriptor.
	//! \return On success, true.
	bool getStatus(int fd);

	//! \brief Get file status.
	//! \param[in] path File path.
	//! \return On success, true.
	bool getStatus(const char* path);

	//! \brief Get file status, but it does not follow the link.
	//! \param[in] path File path.
	//! \return On success, true.
	bool getStatus2(const char* path);

	//! \brief Check a file is socket.
	//! \return If file is socket, true.
	bool isSocket(void) const;

	//! \brief Check a file is regular file.
	//! \return If file is regular file, true.
	bool isRegularFile(void) const;

	//! \brief Check a file is directory.
	//! \return If file is directory, true.
	bool isDirectory(void) const;

	//! \brief Check a file is character device.
	//! \return If file is character device, true.
	bool isCharacterDevice(void) const;

	//! \brief Check a file is block device.
	//! \return If file is block device, true.
	bool isBlockDevice(void) const;

	//! \brief Check a file is FIFO file.
	//! \return If file is FIFO file, true.
	bool isFIFO(void) const;

	//! \brief Check a file is symbolic file.
	//! \return If file is symbolic file, true.
	bool isSymbolicLink(void) const;

public:
	//! \brief Get device.
	//! \return Device.
	dev_t	getDevice(void) const;

	//! \brief Get INODE.
	//! \return INODE.
	ino_t	getINode(void) const;

	//! \brief Get mode.
	//! \return Mode.
	mode_t	getMode(void) const;

	//! \brief Get hard link count.
	//! \return Hard link count.
	nlink_t	getHardLinkCount(void) const;

	//! \brief Get UID.
	//! \return UID.
	uid_t	getUID(void) const;

	//! \brief Get GID.
	//! \return GID.
	gid_t	getGID(void) const;

	//! \brief Get RDevice.
	//! \return RDevice.
	dev_t	getRDevice(void) const;

	//! \brief Get size.
	//! \return Size.
	off_t	getSize(void) const;

	//! \brief Get block size.
	//! \return Block size.
	blksize_t	getBlockSize(void) const;

	//! \brief Get block count.
	//! \return Block count.
	blkcnt_t	getBlockCount(void) const;

	//! \brief Get access time.
	//! \return Access time.
	time_t	getAccessTime(void) const;

	//! \brief Get modification time.
	//! \return Modification time.
	time_t	getModificationTime(void) const;

	//! \brief Get change time.
	//! \return Change time.
	time_t	getChangeTime(void) const;

public:
	explicit PWFileStatus();

	//! \brief Copy constructor.
	//! \param[in] stat Input.
	explicit PWFileStatus(const PWFileStatus& stat);

	//! \brief Copy constructor.
	//! \param[in] file Input.
	explicit PWFileStatus(const PWFile& file);

	//! \brief Copy constructor.
	//! \param[in] fd Input.
	explicit PWFileStatus(int fd);
	virtual ~PWFileStatus();

public:
	//! \brief Assign operator.
	//! \param[in] stat Input.
	//! \return Reference of this object.
	PWFileStatus& operator = (const PWFileStatus& stat);

	//! \brief Assign operator.
	//! \param[in] file Input.
	//! \return Reference of this object.
	PWFileStatus& operator = (const PWFile& file);

	//! \brief Assign operator.
	//! \param[in] fd Input.
	//! \return Reference of this object.
	PWFileStatus& operator = (int fd);

private:
	char m_pData[PWFSTAT_MAX_LEN];	//!< Data
};

};//namespace purewell

#endif//!__FILESTATUS_HPP__


